<?php $this->load->view('provider/template/_begin') ?>
<?php if(!empty($keyword)){ ?>
<script type="text/javascript">
  jQuery(document).ready(function(){
    hightlight('<?php echo $keyword ?>', 'label', $('td'));
  })
</script>
<?php } ?>
<div class="form1">
  <table class="table2">
    <tr>
      <td>&nbsp;</td>
      <td>
        <div class="search">
          <span id="ctl00_Label1" class="text_input">Search</span>
          <form action="<?php echo site_url('provider/promotion/search') ?>" method="get">
            <input type="text" placeholder="Enter your keyword" value="<?php echo isset($keyword) ? $keyword : '' ?>" 
                   id="fulltextSearchText" class="input_search" name="keyword"/>
            <input type="submit" value="" id="ctl00_Button1" class="button_search" 
                   style="background-color: Transparent; border-style: None;"/>
          </form>
        </div>
      </td>
      <td style="width: 385px">
        <div class="button3 mg6" style="margin-top: 0px">
          <div class="button_left_small"></div>
          <div class="button_bg_small"><a href="<?php echo site_url('provider/promotion/create') ?>">Add</a></div>
          <div class="button_right_small"></div>
        </div>
        <div class="button3 mg6" style="margin-top: 0px">
          <div class="button_left_small"></div>
          <div class="button_bg_small"><a href="<?php echo site_url('provider/promotion/check') ?>">Check download</a></div>
          <div class="button_right_small"></div>
        </div>
      </td>
    </tr>
  </table>
  <br/>
  <table class="table3">
    <tr>
      <td class="bgtd">No.</td>
      <td class="bgtd">Name</td>
      <td class="bgtd">Code</td>
      <td class="bgtd">Start date</td>
      <td class="bgtd">Expire date</td>      
      <td class="bgtd">Status</td>
      <td class="bgtd">Downloaded</td>
      <td class="bgtd" colspan="2">&nbsp;</td>
    </tr>
    <?php
    $status = array(
        PROMOTION_NEW => $this->lang->line('label.promotion.status.new'),
        PROMOTION_PEDDING => $this->lang->line('label.promotion.status.pedding'),
        PROMOTION_APPROVED => $this->lang->line('label.promotion.status.approve'),
        PROMOTION_PUBLISH => $this->lang->line('label.promotion.status.publish'),
        PROMOTION_REJECT => $this->lang->line('label.promotion.status.reject'),
        PROMOTION_BLOCK => $this->lang->line('label.promotion.status.block'));
    foreach ($promotions as $i => $promotion) {
      ?>
      <tr>
        <td><?php echo $i + 1 + $offset ?></td>
        <td>
          <a href="<?php echo site_url('provider/promotion/show/' . $promotion['id']) ?>" >
            <label><?php echo $promotion['title'] ?></label>
          </a>
        </td>
        <td>
          <a href="<?php echo site_url('provider/promotion/show/' . $promotion['id']) ?>" >
            <label><?php echo $promotion['code'] ?></label>
          </a>
        </td>
        <td>
          <label><?php echo empty($promotion["start_date"]) ? '' : date($this->setting_model->item('date_format'), $promotion["start_date"]) ?></label>
        </td>
        <td>
          <label><?php echo empty($promotion["end_date"]) ? '' : date($this->setting_model->item('date_format'), $promotion["end_date"]) ?></label>
        </td>
        <td><label><?php echo @$status[$obj["status"]] ?></label></td>
        <td><label><?php echo $this->promotion_download_model->count(array('promotion_id' => $promotion['id'])); ?></label></td>
        <td>
          <a href="<?php echo site_url('provider/promotion/edit/' . $promotion['id']) ?>" >
            <img src="<?php echo base_url() . APPPATH ?>themes/provider/img/xfce-edit.png" 
                 width="25" height="25" alt="" />
          </a>
        </td>
        <td>
          <a href="<?php echo site_url('provider/promotion/delete/' . $promotion['id']) ?>" class="confirm" >
            <img src="<?php echo base_url() . APPPATH ?>themes/provider/img/editdelete.png" 
                 width="25" height="25" alt="" />
          </a>
        </td>
      </tr>
    <?php } ?>
  </table>
  <div class="clearer"></div>
  <div style="margin-top: 10px;text-align: right"><?php echo $paging ?></div>
</div>
<?php $this->load->view('provider/template/_end') ?>
